package com.example.exception;

import com.example.common.Constants;
import com.example.common.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handlerException(Exception e){
        e.printStackTrace();
        return Result.error(Constants.CODE_500,StringUtils.hasLength(e.getMessage())?e.getMessage():"系统异常");
    }
}
